<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>

<link href="<?=$this->baseUrl('template/style.css')?>" rel="stylesheet" type="text/css" />
<link href="<?=$this->baseUrl('jquery/jgrowl/jquery.jgrowl.css')?>" rel="stylesheet" type="text/css" />
<link href="<?=$this->baseUrl("jquery-ui-1.8.7.custom/css/dark-hive/jquery-ui-1.8.7.custom.css")?>" rel="stylesheet" />
<script type="text/javascript" src="<?php echo $this->baseUrl ( "jquery/jquery-1.4.2.min.js" )?>"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl ( "jquery/jquery.js" )?>"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl ( "jquery/js/jquery.jplayer.js" )?>"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl ( "jquery/jgrowl/jquery.jgrowl.js" )?>"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl("jquery-ui-1.8.7.custom/js/jquery-ui-1.8.7.custom.min.js" )?>" type="text/javascript"></script>


</head>
<body>

<div align="center" style="display: none;"  id='dialog' title='Редактировать профиль'>

<table width="300px">
	<tr>
		<td> Имя :  </td>
		<td> <input id='FN' type="text" name="FirstName" value="" style="border: 1px solid black;"/>  </td>
	</tr>
	
	<tr>
		<td> Фамилия :  </td>
		<td>  <input id='LN' type="text" name="LastName" value="" style="border: 1px solid black;"/> </td>
	</tr>
	
	<tr>
		<td> Возраст :  </td>
		<td> <input id='Age' type="text" name="Age" value="" style="border: 1px solid black;"/><br/>  </td>
	</tr>
	
	<tr>
		<td> E-Mail :  </td>
		<td> <input id='Mail' type="text" name="Email" value="" style="border: 1px solid black;"/><br/>  </td>
	</tr>
	
		<tr>
		<td> Логин :  </td>
		<td> <input id='Login' type="text" name="Login" value="" style="border: 1px solid black;"/><br/>  </td>
	</tr>
</table>
 <input id='Password' type="hidden" name="Password" value=""/>
</div>

<div align="center" style="display: none;" id='password' title='Редактировать пароль'>
<table>
	<tr>
		<td> Новый пароль :  </td>
		<td> <input id='new' type="password" name="Pass" value="" style="border: 1px solid black;"/> </td>
	</tr>
	<tr>&nbsp </tr>
	<tr>
		<td> Повтор :  </td>
		<td> <input id='confirm' type="password" name="PassConfirm" value="" style="border: 1px solid black;"/> </td>
	</tr>
</table>
</div>

<script>
function showDialog()
{	
	$.getJSON("<?=$this->baseUrl('users/get-profile');?>",

		function (data)
		{
			$('#FN').attr('value',data.FirstName);
			$('#LN').attr('value',data.LastName);
			$('#Age').attr('value',data.Age);
			$('#Mail').attr('value',data.Email);
			$('#Login').attr('value',data.Login);
			$('#Password').attr('value',data.Password);
			window.userData = data.id;
		}
			
			);
	$('#dialog').dialog(

		{
			resizable : false,
			modal : true,
			hide: 'slide',
			width: '400',
			show: 'slide',
			draggable : false,
				buttons:{ "Сохранить" :
							function()
							{
								$.getJSON("<?=$this->baseUrl('users/save-profile');?>" , 
										{
											'FirstName' : $('#FN').attr('value'),
											'LastName' : $('#LN').attr('value'), 
											'Age' : $('#Age').attr('value'),
											'Email' : $('#Mail').attr('value'),
											'Login' : $('#Login').attr('value'),
											'Password' : $('#Password').attr('value')
										}


										);
								$(this).dialog('close');
							},

							"Отмена" :
							 function()
							{
								$(this).dialog('close');
							}
							
						}
			}
			);
}


</script>

<script>

function setPass()
{	

	$('#password').dialog(

			{
				resizable : false,
				modal : true,
				hide: 'slide',
				width : '400',
				show: 'slide',
				draggable : false,
				buttons:{ "Сохранить" :
							function()
							{
								$.getJSON("<?=$this->baseUrl('users/set-password');?>" , 
										{
											'Password' : $('#new').attr('value'),
											'PassConfirm' : $('#confirm').attr('value') 
										},function(data){$.jGrowl(data);}


										);
								$(this).dialog('close');
							},

							"Отмена" :
							 function()
							{
								$(this).dialog('close');
							}
				}
			}
			);
}

							
</script>



<div id="container"> 
    	<!-- header -->
        <div id="logo"><a href="#">WEBSITE NAME</a></div>
        <?php if ( $this->checkUser() ):?>
        <div id="menu">
            <a href="<?=$this->baseUrl('');?>">Главная</a>
            <a href="<?=$this->baseUrl('playlist');?>">Плейлист</a>
            <a href="#" onclick="showDialog(); return false;">Профиль</a>
            <a href="#" onclick="setPass(); return false;">Пароль</a>
            <a href="#">Информация</a>
            <a href="#">Файлы</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="<?=$this->baseUrl('users/logout');?>">Выход</a>
        </div>
        <?php endif; ?>
        <?php if ( !$this->checkUser() ):?>
        <div align="center" id="menu">
        	<a href="<?=$this->baseUrl('users/register');?>">Регистрация</a>
        </div>
        <?php endif;?>
        
        <!--end header -->
        <!-- main -->
        <div id="main">
        
          <div id="text" >
          </div>
          <?=$this->layout()->content;?>
    </div>
    <!-- end main -->
    <!-- footer -->
    <div id="footer">
            <div id="menu_footer"><a href="#">home</a> | <a href="#">about</a> | <a href="#">products</a> |  <a href="#">services</a> | <a href="#">pricing</a> | <a href="#">contact</a> | <a href="#">sitemap</a> | <a href="#">testimonials</a> | <a href="#">etc.</a></div>
            <div id="left_footer">&copy; Copyright 2008 <strong>Your Website</strong></div>
            <div id="right_footer">
Design by <a href="http://www.realitysoftware.ca" title="Web Design"><strong>Reality Software</strong></a> &amp; <a href="http://www.flashmp3player.org" title="Free Flash MP3 Player"><strong>Flash Music Player</strong></a>
			<div style="display:none;"><a href="http://csstemplatesfree.net">free website templates for free</a></div>
             </div>
    </div>
    <!-- end footer -->
</div>
</body>

<script>
function url(str)
{

return "<?=$this->baseUrl("")?>"+str;
	
}
</script>

</html>
